package com.lyn.andplugin.viewModel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.lyn.pluginapi.entity.PluginInfo
import com.lyn.pluginapi.entity.WrapPluginInfo
import com.lyn.pluginhost.PluginHostManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 *
 * @author longyn 2025/07/10
 * @version 1.0.0
 */
class PluginViewModel : ViewModel() {

    val pluginInfoLiveData:MutableLiveData<MutableList<WrapPluginInfo>> = MutableLiveData()

    fun loadAllPlugin(){
        viewModelScope.launch(Dispatchers.IO){
            //加载全部插件
            val pluginInfos = PluginHostManager.instance.loadAllPlugin()
            pluginInfoLiveData.postValue(pluginInfos)
        }
    }
}